<?php

namespace app\common\model\mysql;

use think\Model;

class demo extends Model
{
    public function getStatusTextAttr($value, $data)
    {
        $status = [
            1 => '单规格',
            2 => '统一规格'
        ];
        return $status[$data['status']];
    }

    public function getDemoDataByCategoryId($categoryId, $limit = 5)
    {
        $results = $this->where("category_id", $categoryId)
            ->limit(5)
            ->order('id', 'desc')
            ->select()->toArray();
        dump($results);
        return $results;
    }
}